/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server.domain.threads;

import Server.domain.*;

import java.util.StringTokenizer;

/**
 *
 * @author user
 */
public class Translator extends Thread
{
	protected PlayerList playerList;
	protected String message;
	
	public Translator(PlayerList pL,String m)
	{
		playerList = pL;
		message = m;
	}
	public synchronized void run()
	{
		StringTokenizer part = new StringTokenizer(message);
		Player player = playerList.getByName(part.nextToken());
		
		player.resetKeys();
		int temp = Integer.parseInt(part.nextToken());
		if(temp==1)
			player.setUp(true);
		else
			player.setUp(false);
		temp = Integer.parseInt(part.nextToken());
		if(temp==1)
			player.setDown(true);
		else
			player.setDown(false);
		temp = Integer.parseInt(part.nextToken());
		if(temp==1)
			player.setLeft(true);
		else
			player.setLeft(false);
		temp = Integer.parseInt(part.nextToken());
		if(temp==1)
			player.setRight(true);
		else
			player.setRight(false);
	}
}
